/*
 * Classe que representa uma conexão ao banco
 */
package persistencia;

import java.sql.*;


public class ConnectionDAO {

    protected String driver = "oracle.jdbc.driver.OracleDriver";
    protected Connection connection = null;
    protected String connection_string;
    protected String user;
    protected String pwd;        


    /*
     * Construtor da conexão
     */
    public ConnectionDAO(String usuario, String senha, String host, int porta, String sid) throws ClassNotFoundException{
        this.user = usuario;
        this.pwd = senha;
        this.connection_string = "jdbc:oracle:thin:@" + host + ":" + porta + ":" + sid;
        Class.forName(driver);        
    }
    
    public Connection getConnection() throws SQLException{
        return connection = DriverManager.getConnection(this.connection_string, this.user, this.pwd);
    }

    public String getUser() {
        return this.user;
    }
   
    public void closeConnection() throws SQLException {
        this.connection.close();
    }
}
